﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using Stauffware.Common.Core;
using Stauffware.Common.Time;

namespace UnitTests
{
	class _Program
	{
		// The Essentials_UnitTests project is intended primarily for use with NUnit.
		// It is built as a console app rather than a DLL to facilitate ad-hoc
		// testing under the debugger.
	
		public static void Main ( )
		{
		//	UnitTests.CmdLineParser.OtherUnitTests.Help();

		//	TestDateParse();

		//	GenerateDatePatterns(System.Console.Out);

			NormalizePath();
		}

		static void NormalizePath ( )
		{
			string input = "a/b/c/../../x";
			string output = Stauffware.Common.IO.FileSystemPath.NormalizePath(input, '\\');
		}

		static void DumpCulture ( )
		{
			IFormatProvider ifp = CultureInfo.CurrentCulture;
			System.Console.WriteLine("CultureInfo.CurrentCulture is " + ifp.GetType().FullName);
		}

		static void TestDateParse ( )
		{
			DateParser parser = new DateParser(DateParseOptions.ParseEntireInput);

			DateParse dp = parser.Parse("3/29/2017");

		}

		static void GenerateDatePatterns (System.IO.TextWriter tw)
		{

			foreach (string y in Strings("yy", "yyyy"))
			{
				foreach (string m in Strings("M", "MM", "MMM", "MMMM"))
				{
					foreach (string d in Strings("d", "dd"))
					{
						foreach (string sep in Strings(" ", "-", "\\/"))
						{
							tw.Write(("@\"" + y + sep + m + sep + d + "\",").PadRight(20));
							tw.Write(("@\"" + m + sep + d + sep + y + "\",").PadRight(20));
							tw.Write(("@\"" + d + sep + m + sep + y + "\",").PadRight(20));
							tw.WriteLine();
						}

						if (m.Length > 2)	// if month is a name, not a number
						{
							tw.Write("@\"" + d + m + y + "\",");
							tw.WriteLine();
						}
					}
				}
			}
		}

		// syntactic sugar for GenerateDatePatterns
		static string[] Strings (params string[] inputs)
		{
			return inputs;
		}
	}
}
